<?php
declare(strict_types=1);

namespace plugin\ky_black\app\admin\controller;

use support\Request;
use support\Response;
use plugin\ky_black\app\admin\model\User;

class UserController extends BaseController
{
    /**
     * 搜索用户
     */
    public function search(Request $request): Response
    {
        $params = $request->get('params', []);
        $keyword = $params['keyword'] ?? '';
        
        if (!$keyword) {
            return $this->success([]);
        }

        $users = User::where('name', 'like', "%{$keyword}%")
            ->orWhere('phone', 'like', "%{$keyword}%")
            ->limit(10)
            ->get(['user_id', 'name', 'phone']);
            
        return $this->success($users);
    }
} 